<?php
namespace Admin\Controller;

use Admin\Controller\GlobalController;

class UserController extends GlobalController
{
    //杂志列表
    public function getlist()
    {
        $pageSize = 20;
        $where = array();
        $user_id = I('get.user_id', 0, 'intval');
        if (!empty($user_id)) {
            $where['user_id'] = $user_id;
        }
        $this->assign('user_id', $user_id == 0 ? '' : $user_id);
        $username = I('get.username', '', 'trim');
        if (!empty($username)) {
            $where['username'] = $username;
        }
        $this->assign('username', $username);
        $nickname = I('get.nickname', '', 'trim');
        if (!empty($nickname)) {
            $where['nickname'] = $nickname;
        }
        $this->assign('nickname', $nickname);
        $userModel = M('user');
        $count = $userModel->where($where)->count();
        $pageObj = new \Admin\Util\Page($count, $pageSize);
        $list = $userModel->where($where)->order('user_id desc')->limit($pageObj->firstRow . ',' . $pageObj->listRows)->select();
        $this->assign('list', $list);
        $this->assign('page', $pageObj->show());
        $this->display();
    }

    //添加或者修改
    public function save()
    {
        $this->display();
    }
}